using System.Reflection;

namespace System.Utility.Data.Validation
{
	public class RequireValidatorFactory
	{
		public RequireValidatorFactory()
		{
		}

		public static RequireValidator CreateValidator(string errorMsg, string text, PropertyInfo propertyInfo)
		{
			RequireValidator stringRequireValidator;
			Type propertyType = propertyInfo.PropertyType;
			if (propertyType.Equals(typeof(string)))
			{
				stringRequireValidator = new StringRequireValidator(errorMsg, text, propertyInfo);
			}
			else if (!propertyType.Equals(typeof(DateTime)))
			{
				stringRequireValidator = new RequireValidator(errorMsg, text, propertyInfo);
			}
			else
			{
				stringRequireValidator = new DatetimeRequireValidator(errorMsg, text, propertyInfo);
			}
			return stringRequireValidator;
		}
	}
}